package com.basaji.common;

import javax.servlet.http.HttpServletRequest;

public class PageUtil {

	public static Page getPage(HttpServletRequest request, int total,
			int pageSize) {
		int _pageSize = 10;
		int _curPage = 1;
		String _p = request.getParameter("p");
		if (_p != null) {
			_curPage = Integer.valueOf(_p);
			if (_curPage == 0) {
				_curPage = 1;
			}
		}
		_pageSize = pageSize;
		int _start = (_curPage - 1) * _pageSize;
		if (_start > total) {
			_start = 0;
		}

		Page _page = new Page(total, 0, _pageSize, _curPage, 8);
		_page.setStart(_start);

		return _page;

	}
}
